<template>
	<view>
		<button @click="callStorageFun(1)">setStorage</button>
		<button @click="callStorageFun(2)" type="primary" plain="true">getStorage</button>
		<button @click="callStorageFun(3)" type="primary">getStorageInfo</button>
		<button @click="callStorageFun(4)" type="warn" plain="true">removeStorage</button>
		<button @click="callStorageFun(5)" type="warn">clearStorage</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				result:'aaa',
				account:'null'
			}
		},
		methods: {
			callStorageFun(parm){
				console.log("callStorageFun==>parm "+parm);
				switch(parm){
					case 1:
						uni.setStorage({//花括号内是对象,异步接口函数有回调
							key:'username',
							data:'hhl',
							success(){
								console.log("username 存储好了");
							}
						});
						console.log("success");
						break;
					case 2:
						uni.getStorage({
							key:'username',
							success:function(result){
								console.log("success result.data="+result.data);
								
							},
							fail(error){
								console.error("fail"+error);
							}
						});
						break;
					case 3:
						uni.getStorageInfo({
							success:function(result){
								console.log("get:"+result.keys);
							}
						});	
						break;
				}	
			}
		}
	}
</script>

<style>
button{
	margin: 15rpx;
}
</style>
